﻿<cfsilent>
	<cfscript>

		temFile = GetTempDirectory() & createUUID() & ".xls";
		downFile = URLEncodedFormat( "专升本模板", "utf-8");
		
		excel = getProperty("serviceFactory").getBean("spreadSheetObject");

		/* 创建工作簿 */
		spreadsheetObj = excel.SpreadSheetNew( "专升本数据", false);		

		/* 添加表头 */
		excel.SpreadsheetAddrow(spreadsheetObj, "学号,姓名,性别,身份证,民族,专科学校,转入班级,转入专业,转入学院,曾用名,出生日期,家庭地址,邮编,审批文号");		
		
		/* 添加民族信息 */
		excel.SpreadsheetCreateSheet (spreadsheetObj, "民族参考信息");
		excel.SpreadsheetSetActiveSheet (spreadsheetObj, "民族参考信息");
		
		excel.SpreadsheetAddrow(spreadsheetObj, "民族名称");
		
		sql = "	SELECT
					t.nation_name
				FROM
					t_nation t";
		
		queryObj = new Query( datasource=application.dnsSlave );
		rs_nation = queryObj.execute( sql=sql ).getResult();
		
		for( a = 1; a lte rs_nation.recordCount; a++){
			excel.SpreadsheetAddrow(spreadsheetObj, rs_nation["nation_name"][a]);
		}
		
		excel.SpreadsheetSetActiveSheet (spreadsheetObj, "专升本数据");
		
		excel.SpreadSheetWrite(spreadsheetObj, temFile, true);

	</cfscript>

	<cfheader name="Content-Disposition" value="attachment; filename=#downFile#.xls" />
	<cfcontent file="#temFile#" reset="yes" type="application/msexcel" deletefile="yes" />	

</cfsilent>